<?php 
session_cache_expire(999999999);
include 'operations/connection.php';
$sql2="select DISTINCT buying_document.company 
from approvedoc,buying_document 
where approvedoc.IDTypeDoc in(13,15) 
and approvedoc.IDApproveDoc=buying_document.document_id";
$sql3="SELECT ac_customer.CustomerID,ac_customer.CustomerName from ac_customer  ";
$result1=mysql_query($sql3);

$result=mysql_query($sql2);
if(mysql_num_rows($result)>0){
	?>
	<table width="100%" border="1">
		<tr>
			<td><?php echo mysql_num_rows($result);?></td>
		</tr>
		<tr>
			<td>TT</td>
			<td>company</td>
		</tr>
	<?php 
	$i=1;
	while($row=mysql_fetch_array($result)){
		$sql3="SELECT ac_customer.CustomerID,ac_customer.CustomerName from ac_customer where ac_customer.CustomerName like '%".$row[company]."%'";
		$result1=mysql_query($sql3);
		if(mysql_num_rows($result1)>0){
		?>
		<tr>
			<td><?php echo $i;?></td>
			<td><?php echo $row[company];?></td>
		</tr>
		<?php 
		}else{
			/*$a= (string)(microtime(true)*1000);
			$b=split('\.',$a);
			$CustomerID="KHTT".$b[0];
			$sql="insert into ac_customer (CustomerID,CustomerName,CreatedDate,Activest) values ('".$CustomerID."','".$row[company]."',date(now()),".$Activest.")";
			mysql_query($sql);*/
		}
		$i++;
	}
	?>
	</table>
	<?php 
}else {
	echo "lỗi";
}



?>